package thread.demo.synchronousQueue;

import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.TimeUnit;

public class SynchronousQueue_Put {
  public static void main(String[] args) throws InterruptedException {
    SynchronousQueue<String> queue = new SynchronousQueue<>();
    
    new Thread(() -> {
      try {
        queue.put("消息");
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }).start();
    
    TimeUnit.SECONDS.sleep(4);
    
    new Thread(() -> {
      System.out.println(queue.poll());
    }).start();
  }
}
